package matrix;

/**
 * Реализация {@linkplain matrix.IRangeStorage Хранилища} {@linkplain matrix.ICell Ячеек} через двумерный массив
 * <p> Итератор реализован как вложенный (inner) класс.
 */
public class CStorageAsArray implements IRangeStorage {
	private ICell[][] m_a2dArray;

	class Iterator implements IRangeIterator {
		private int m_iCurrentRow = 1;
		private int m_iCurrentColumn = 1;

		@Override
		public boolean hasNext() {
			return ((m_iCurrentRow <= m_oRange.rows()) && (m_iCurrentColumn < m_oRange.columns()));
		}

		@Override
		public ICell next() {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public void remove() {
			// TODO Auto-generated method stub
			
		}

		@Override
		public boolean hasNextRow() {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public IRange nextRow() {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public boolean hasNextColumn() {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public IRange nextColumn() {
			// TODO Auto-generated method stub
			return null;
		}
		
	}

	public CStorageAsArray(int aRows, int aColumns) {
		m_a2dArray = new ICell[aRows][aColumns];
	}

	@Override
	public void addCell(ICell aCell, int aRow, int aColumn) {
		if (aCell == null) {
			throw new IllegalArgumentException("aCell can't be null");
		}
		if ((aRow > m_a2dArray.length) || (aColumn > m_a2dArray[0].length)) {
			throw new IllegalArgumentException("aRow or aColumn too large");
		}
		m_a2dArray[aRow-1][aColumn-1] = aCell;
	}

	@Override
	public IRangeIterator iterator(int aRow, int aColumn, int aRows,
			int aColumns) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ICell getCell(int aRow, int aColumn) {
		// TODO Auto-generated method stub
		return null;
	}

}
